package datastructure.sort;

/**
 * @author MaoLin Wang
 * @description
 * @date 2020-08-24 16:00
 */
public class ShellSort {
    public static void sheelSort(int[]arr){
       for (int group=arr.length/2;group>=1;group/=2){
           for (int i=group;i<arr.length;i++){
               int temp=arr[i];

               int j;
               for (j=i;j-group>=0 && temp<arr[j-group];j-=group){
                   arr[j]=arr[j-group];
               }
               arr[j]=temp;
           }
       }
    }
    public static void main(String[]args) {
        int[]arr=new int[]{13,42,1,2,56,2,65,74,2,14,235,62};
        sheelSort(arr);
        for (int p : arr) {
            System.out.println(p);
        }
    }
}
